package com.runchinaup.smartbelt.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import com.runchinaup.smartbelt.ble.BlueGattCallbackHelper;

/**
 * Created by liber on 2018/2/5.
 */

public class MessageReceiver extends BroadcastReceiver {

    public static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED";
    private BlueGattCallbackHelper gattCallbackHelper = BlueGattCallbackHelper.getBlueGattCallbackHelper();

    @Override
    public void onReceive(Context context, Intent intent) {
        SharedPreferences shared = context.getSharedPreferences("buttonIsOpen", Context.MODE_PRIVATE);
        boolean isMessage = shared.getBoolean("isMessage", false);
        String action = intent.getAction();
        if (SMS_RECEIVED_ACTION.equals(action)) {
            if (isMessage) {
                gattCallbackHelper.phoneMessageRemind();
            }
        }
    }
}
